<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>排序</title>
    <script>
        let arr = [3, 4, 8, 1, 6, 2, 5, 7, 9];
        //冒泡
        // for (let i = 1; i < arr.length; i++) {
        //     for (let j = 0; j < arr.length - i; j++) {
        //         if (arr[j] > arr[j + 1]) {
        //             let temp = arr[j];
        //             arr[j] = arr[j + 1];
        //             arr[j + 1] = temp;
        //         }
        //     }
        // }
        //选择
        for (let i = 0; i < arr.length - 1; i++) {
            for (let j = i + 1; j < arr.length ; j++) {
                if (arr[i] > arr[j]) {
                    let temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
        console.log(arr)
        console.log(typeof arr)
    </script>
</head>

<body>

</body>

</html>